<html>
<head>
      <title>operate the iframe on other domain</title>
  <script>
    function sendMessage() {
      var frm = document.getElementById('bIframe')
      frm.contentWindow.postMessage('yellow', '*')
    }


    window.addEventListener('message', function(ev) {
      // if (ev.source !== window.parent) {return;}
      var data = ev.data
      document.body.style.background = data
    }, false)
  </script>
</head>
<body>
   
<button id="send" onclick="sendMessage()">send message</button>
    <br/>
   
<iframe style="width:300px; height:400px;" id="bIframe" src="http://localhost:64835/b.html">
     
</iframe>
</body>
</html>